<!DOCTYPE html>
<html lang="cn">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.1.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="引言REST Client 是一个 VSCode 插件，使我们可以直接在 VSCode 中直接发送http请求，目前我用它来代替 postman 做一些简单接口测试。 REST Client allows you to send HTTP request and view the response in Visual Studio Code directly  说起测试接口，大家一定会想起 pos">
<meta property="og:type" content="article">
<meta property="og:title" content="REST Client 插件的使用">
<meta property="og:url" content="http://example.com/2021/07/12/08-restclient/index.html">
<meta property="og:site_name" content="小马向前走">
<meta property="og:description" content="引言REST Client 是一个 VSCode 插件，使我们可以直接在 VSCode 中直接发送http请求，目前我用它来代替 postman 做一些简单接口测试。 REST Client allows you to send HTTP request and view the response in Visual Studio Code directly  说起测试接口，大家一定会想起 pos">
<meta property="og:locale">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-28456.png">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-13246.png">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-26417.png">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-21529.gif">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-128.png">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/restClient-25289.png">
<meta property="og:image" content="http://example.com/2021/07/12/08-restclient/qrcode-12cm.jpg">
<meta property="article:published_time" content="2021-07-12T04:08:33.000Z">
<meta property="article:modified_time" content="2022-02-24T09:33:24.000Z">
<meta property="article:author" content="maning">
<meta property="article:tag" content="vscode">
<meta property="article:tag" content="rest">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/2021/07/12/08-restclient/restClient-28456.png">

<link rel="canonical" href="http://example.com/2021/07/12/08-restclient/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'cn'
  };
</script>

  <title>REST Client 插件的使用 | 小马向前走</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">小马向前走</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="cn">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/07/12/08-restclient/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="maning">
      <meta itemprop="description" content="小马向前走">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="小马向前走">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          REST Client 插件的使用
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2021-07-12 12:08:33" itemprop="dateCreated datePublished" datetime="2021-07-12T12:08:33+08:00">2021-07-12</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2022-02-24 17:33:24" itemprop="dateModified" datetime="2022-02-24T17:33:24+08:00">2022-02-24</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index"><span itemprop="name">工具</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><p>REST Client 是一个 VSCode 插件，使我们可以直接在 VSCode 中直接发送http请求，目前我用它来代替 postman 做一些简单接口测试。</p>
<p>REST Client allows you to send HTTP request and view the response in Visual Studio Code directly</p>
<p><img src="/2021/07/12/08-restclient/restClient-28456.png" alt="restClient-1"></p>
<p>说起测试接口，大家一定会想起 postman ，那在引入 REST Client 插件之前，需要解答一个问题，难道 postman 不香么，为什么还要引入新工具? 实际上 postman 很香，只是对于一些入参简单的请求，用 postman 感觉太重了，而且如果接口数量很多，导致打开很多标签。</p>
<p><strong>一直以来我也在寻找更好的方案，一个不用切换窗口的方案</strong>  – 终于在使用 VSCode 一段时间后，我找到了 REST Client 插件，初看 REST Client 插件的时候，会觉得他十分简陋，但是在使用一段时间后会发现在 REST Client 插件中已经有完成接口测试所需的大部分功能。</p>
<p><strong>我总结了3点使用REST Client插件的好处</strong></p>
<ol>
<li>便于分享，因为是纯文本，联调时可以做为一个成果物，发给前端开发同事做为测试列表，这是我使用它的主要原因</li>
<li>不用切换标签，通过###分隔符，同一个HTTP文件里可以包含多个HTTP请求， 不像Postman，不同的HTTP请求需要放在不同的tab里</li>
<li>可以更直接的接触到http的相关知识，因为不论请求还是返回都是文本，这样可以更直接的感受到http请求的细节</li>
</ol>
<h1 id="相关资料"><a href="#相关资料" class="headerlink" title="相关资料"></a>相关资料</h1><p>github </p>
<p><a target="_blank" rel="noopener" href="https://github.com/Huachao/vscode-restclient">https://github.com/Huachao/vscode-restclient</a></p>
<h1 id="关于安装"><a href="#关于安装" class="headerlink" title="关于安装"></a>关于安装</h1><p>直接在插件商店中搜索 REST Client 安装即可</p>
<p><img src="/2021/07/12/08-restclient/restClient-13246.png" alt="restClient-13246"></p>
<h1 id="简单使用"><a href="#简单使用" class="headerlink" title="简单使用"></a>简单使用</h1><p>本节列出几个示例，指引大家快速入门</p>
<h2 id="示例1-get请求示例"><a href="#示例1-get请求示例" class="headerlink" title="示例1 get请求示例"></a>示例1 get请求示例</h2><p>这里演示如何发送一个get请求，从该示例中你会掌握基本的用法</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@IP=127.0.0.1:8083</span><br><span class="line"></span><br><span class="line">### get 请求示例</span><br><span class="line">GET http://&#123;&#123;IP&#125;&#125;/helloJson/testParam?name=hello</span><br></pre></td></tr></table></figure>

<p>当一个文件的后缀名是.http 或者 .rest时，VSCode 会自动识别成接口文件</p>
<p>在VSCode中 <strong>用三个#号 ### 表示一个接口的开始</strong>，其下方会有一个 Send Request的按钮，当点击该按钮时会发送请求，之后会在窗口右边显示请求返回的内容</p>
<p><img src="/2021/07/12/08-restclient/restClient-26417.png" alt="restClient-26417"></p>
<h2 id="示例2-post请求示例"><a href="#示例2-post请求示例" class="headerlink" title="示例2 post请求示例"></a>示例2 post请求示例</h2><p>这里演示如何发送一个post请求</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">@IP=127.0.0.1:8083</span><br><span class="line"></span><br><span class="line">### post 请求示例</span><br><span class="line">POST &#123;&#123;IP&#125;&#125;/authorize/register</span><br><span class="line"><span class="attribute">Content-Type</span>: application/json</span><br><span class="line"></span><br><span class="line">&#123;</span><br><span class="line">    &quot;name&quot;: &quot;小天&quot;，</span><br><span class="line">    &quot;username&quot;: &quot;sky&quot;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>注意data 与请求头之间有空行</strong></p>
<h1 id="高阶使用"><a href="#高阶使用" class="headerlink" title="高阶使用"></a>高阶使用</h1><p>其实REST Client还有很多的功能，有需求的同学可以慢慢挖掘，笔者列出了一些比较有用的高阶技巧。</p>
<h2 id="示例1-变量的使用"><a href="#示例1-变量的使用" class="headerlink" title="示例1 变量的使用"></a>示例1 变量的使用</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@IP=127.0.0.1:8083</span><br><span class="line"></span><br><span class="line">### get 请求示例</span><br><span class="line">GET http://&#123;&#123;IP&#125;&#125;/pgp/helloJson/testParam?name=hello</span><br></pre></td></tr></table></figure>

<p>实际上细心的你可能已经发现，在前面的简单示例中IP并没有写死，而是使用了一个变量，这样做的好处是可以快速切换环境。</p>
<p>当然这里的变量可以不光是变量，还可以是环境变量，其在使用方式上没有差别。</p>
<h2 id="示例2-Get请求参数写成多行"><a href="#示例2-Get请求参数写成多行" class="headerlink" title="示例2 Get请求参数写成多行"></a>示例2 Get请求参数写成多行</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">### get 请求 参数写到多行示例</span><br><span class="line">GET https://example.com/comments</span><br><span class="line">    ?page=2</span><br><span class="line">    &amp;pageSize=10</span><br></pre></td></tr></table></figure>

<p>如果参数有很多，写在一行上不方便阅读和修改，则可以像这里一样分行写，一行一个。</p>
<h2 id="示例3-添加头信息"><a href="#示例3-添加头信息" class="headerlink" title="示例3 添加头信息"></a>示例3 添加头信息</h2><figure class="highlight http"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">### 测试 不拦截 请求头中加标记</span><br><span class="line">GET http://&#123;&#123;IP&#125;&#125;/pgp/helloJson/testMap</span><br><span class="line"><span class="attribute">XX-NOT-INTERCEPT:true</span></span><br></pre></td></tr></table></figure>

<p>如果需要添加自定义的头信息可以这样添加。</p>
<h2 id="示例4-添加cookie"><a href="#示例4-添加cookie" class="headerlink" title="示例4 添加cookie"></a>示例4 添加cookie</h2><figure class="highlight http"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">### 测试 cookie</span><br><span class="line">GET http://&#123;&#123;IP&#125;&#125;/pgp/helloJson/testCookie</span><br><span class="line"><span class="attribute">Cookie</span>: eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIxNjI2MTA1NjAwIiwic3ViIjoic2t5Iiwib2ZmaWNpYWxBY2NvdW50cyI6IuWwj-mprOWQkeWJjei1sCIsImlhdCI6MTYyNjE3MTcwMywiZXhwIjoxNjI2MTcyMjAzfQ.PTzL-lw6NQb2qhQg_-q2DWmMOe-1IcpEWcKyLv2rQfQhnrJiIEnVEd0s4FKxre5qVkyfc9b40u31dvJS-ejYUg</span><br></pre></td></tr></table></figure>

<p>这里演示在请求中如何添加cookie， 实际上cookie也是头的一部分，和添加头没什么区别。</p>
<h2 id="示例5-代码生成"><a href="#示例5-代码生成" class="headerlink" title="示例5 代码生成"></a>示例5 代码生成</h2><p>代码生成也是REST Client里一个很方便的功能，可以方便的将HTTP请求生成代码片段或者curl命令。</p>
<p><strong>Generate Code Snippet</strong></p>
<p>你可以方便地通过 Generate Code Snippet 命令来把HTTP请求生成出不同编程语言的代码：JavaScript， Python， C， C#， Java， PHP， Go， Ruby， Swift等等主流语言。</p>
<p><img src="/2021/07/12/08-restclient/restClient-21529.gif" alt="restClient-21529"></p>
<p><strong>Copy Request As cURL</strong></p>
<p>也可以通过Copy Request As cURL功能将HTTP请求生成 <code>curl</code> 命令，这个方法在运维排错时特别有用，在运维时有可能网络不通，需要登录到内网机器执行curl命令测试接口是否正常，但也许你对curl命令不熟悉， 不能很快写出命令，则可以借助REST Client 直接生成curl命令。</p>
<p><img src="/2021/07/12/08-restclient/restClient-128.png" alt="restClient-128"></p>
<p>选中接口文本–&gt; 右键 Copy Request As cURL</p>
<p><img src="/2021/07/12/08-restclient/restClient-25289.png" alt="restClient-25289"></p>
<p>如下是生成的curl命令</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">curl --request POST \</span><br><span class="line">  --url <span class="string">&#x27;http://127.0.0.1:8083/blue/sql/queryListByKeyWithParam?key=00_0005&#x27;</span> \</span><br><span class="line">  --header <span class="string">&#x27;content-type: application/json&#x27;</span> \</span><br><span class="line">  --header <span class="string">&#x27;user-agent: vscode-restclient&#x27;</span> \</span><br><span class="line">  --data <span class="string">&#x27;&#123;&quot;dataType&quot;:&quot;default&quot;,&quot;code&quot;:[&quot;001&quot;,&quot;002&quot;]&#125;&#x27;</span></span><br></pre></td></tr></table></figure>





<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>本节演示了REST Client的一些用法，希望大家把 VSCode 转化为一个 REST 接口测试的利器。</p>
<hr>
<p>微信端的朋友也可关注我的公众号</p>
<p><strong>小马向前走</strong></p>
<p><img src="/2021/07/12/08-restclient/qrcode-12cm.jpg" alt="qrcode-12cm"></p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/vscode/" rel="tag"># vscode</a>
              <a href="/tags/rest/" rel="tag"># rest</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/02/08/07-rest-template/" rel="prev" title="RestTemplate在非springboot工程中的使用">
      <i class="fa fa-chevron-left"></i> RestTemplate在非springboot工程中的使用
    </a></div>
      <div class="post-nav-item">
    <a href="/2022/02/24/09-restclient2/" rel="next" title="为什么使用REST Client插件?">
      为什么使用REST Client插件? <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BC%95%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">引言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%9B%B8%E5%85%B3%E8%B5%84%E6%96%99"><span class="nav-number">2.</span> <span class="nav-text">相关资料</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%B3%E4%BA%8E%E5%AE%89%E8%A3%85"><span class="nav-number">3.</span> <span class="nav-text">关于安装</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8"><span class="nav-number">4.</span> <span class="nav-text">简单使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B1-get%E8%AF%B7%E6%B1%82%E7%A4%BA%E4%BE%8B"><span class="nav-number">4.1.</span> <span class="nav-text">示例1 get请求示例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B2-post%E8%AF%B7%E6%B1%82%E7%A4%BA%E4%BE%8B"><span class="nav-number">4.2.</span> <span class="nav-text">示例2 post请求示例</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E9%AB%98%E9%98%B6%E4%BD%BF%E7%94%A8"><span class="nav-number">5.</span> <span class="nav-text">高阶使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B1-%E5%8F%98%E9%87%8F%E7%9A%84%E4%BD%BF%E7%94%A8"><span class="nav-number">5.1.</span> <span class="nav-text">示例1 变量的使用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B2-Get%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0%E5%86%99%E6%88%90%E5%A4%9A%E8%A1%8C"><span class="nav-number">5.2.</span> <span class="nav-text">示例2 Get请求参数写成多行</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B3-%E6%B7%BB%E5%8A%A0%E5%A4%B4%E4%BF%A1%E6%81%AF"><span class="nav-number">5.3.</span> <span class="nav-text">示例3 添加头信息</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B4-%E6%B7%BB%E5%8A%A0cookie"><span class="nav-number">5.4.</span> <span class="nav-text">示例4 添加cookie</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%A4%BA%E4%BE%8B5-%E4%BB%A3%E7%A0%81%E7%94%9F%E6%88%90"><span class="nav-number">5.5.</span> <span class="nav-text">示例5 代码生成</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%80%BB%E7%BB%93"><span class="nav-number">6.</span> <span class="nav-text">总结</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">maning</p>
  <div class="site-description" itemprop="description">小马向前走</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">18</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">maning</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
